﻿var watermark_loading = false;
var compress_loading = false;
$(function () {
    //批量加水印
    $("#btnAddWatermark").bind('click', function () {
        $("#form1").ajaxSubmit({
            beforeSubmit: function (formData, jqForm, options) {
                if (confirm("该操作将给本栏目下的所有图片添加水印，添加后的图片水印无法去除，确定要继续吗？") && watermark_loading == false) {
                    $("#loading_img").html("<img src='../images/loading.gif' /> 水印添加中，请稍等...");
                    watermark_loading = true;
                }
                else {
                    watermark_loading = false;
                    return false;
                }
            },
            success: function (data, textStatus) {
                alert(data.msgbox);
                $("#loading_img").html("");
                watermark_loading = false;
            },
            error: function (data, status, e) {
                alert("水印添加失败，错误信息：" + e);
                $("#loading_img").html("");
                watermark_loading = false;
            },
            url: "../../tools/watermark_ajax.ashx?act=all",
            type: "get",
            dataType: "json",
            timeout: 600000
        });
    });
    //批量压缩图片
    $("#btnCompress").bind('click', function () {
        $("#form1").ajaxSubmit({
            beforeSubmit: function (formData, jqForm, options) {
                if (confirm("该操作将压缩本栏目下的所有图片，压缩后无法恢复，确定要继续吗？") && compress_loading == false) {
                    $("#loading_img").html("<img src='../images/loading.gif' /> 图片压缩中，请稍等...");
                    compress_loading = true;
                }
                else {
                    compress_loading = false;
                    return false;
                }
            },
            success: function (data, textStatus) {
                alert(data.msgbox);
                $("#loading_img").html("");
                compress_loading = false;
            },
            error: function (data, status, e) {
                alert("图片压缩失败，错误信息：" + e);
                $("#loading_img").html("");
                compress_loading = false;
            },
            url: "../../tools/compress_ajax.ashx?act=all",
            type: "get",
            dataType: "json",
            timeout: 600000
        });
    });
});


